<template>
    <div class="pageFoot joinfoot">
        <div class="pc-pageFoot">
            <img class="logo" src="../../assets/images/bounty/logo1.png" alt="Nature's Bounty">
            <div class="item-content">
                <!-- 产品分类 -->
                <div class="item">
                    <div class="item-title">Products</div>
                    <div class="item-list">
                        <div class="item-list-item" v-for="item in productCategoryTree" :key="item.id"
                            :title="item.name" @click="openProductChildDropdown(item.id)">{{ item.name }}</div>
                    </div>
                </div>

                <!-- Give & Share -->
                <div class="item">
                    <div class="item-title">Give & Share</div>
                    <div class="item-list limit-height" style="display: flex;flex-direction: column;flex-wrap: wrap;">
                        <div class="item-list-item" v-for="item in charityList" :key="item.id" :title="item.title"
                            @click="openGiveShare(item.id)">
                            {{ item.title }}</div>
                    </div>
                </div>

                <!-- Learn -->
                <div class="item">
                    <div class="item-title">Learn</div>
                    <div class="item-list">
                        <div class="item-list-item" @click="toBlogList">Harvest Gain Blog</div>
                        <div class="item-list-item" @click="toWomensWellness">Women's Wellness Hub</div>
                    </div>
                </div>

                <!-- Join Newsletter -->
                <div class="item newsletter">
                    <div class="item-title">Join Our Newsletter</div>
                    <p class="newsletter-desc">Receive latest news, special offers and new product launches!</p>
                    <div class="newsletter-form">
                        <input type="email" placeholder="Your email address" v-model="email" class="email-input">
                        <button class="subscribe-button" @click="subscribe()">Subscribe</button>
                    </div>
                    <div class="success-message" v-if="subscribed">
                        <span class="checkmark">✓</span> Thank you for subscribing
                    </div>
                </div>
            </div>

            <!-- 社交媒体 -->
            <div class="social-media">
                <div class="social-content">
                    <div class="contact-us item">
                        <div class="title">Contact Us</div>
                        <div class="content" style="margin-top: 15px">
                            <p>Company Name: Harvest Gain Biotechnology HGBC Corporation</p>
                            <p>Company Address: 1500 N GRANT ST STE R DENVER CO 80203 US</p>
                            <p>Contact Number: +1(303) 258-6400</p>
                            <div style="display: flex;align-items:start">
                                <p>Customer Support: </p>
                                <div>
                                    <p>hgbc@harvesthgbc.com</p>
                                    <p>support@harvesthgbc.com</p>
                                    <p> service@harvesthgbc.com</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="follow-us item">
                        <div class="title">Follow Us</div>
                        <div class="content" style="margin-top: 15px">
                            <div class="follow-us-item" @click="toFacebook">
                                <img class="Nature-item" title="Share on Facebook"
                                    src="../../assets/images/bounty/组 1.png" alt="">
                                <p>Facebook</p>
                            </div>
                            <div class="follow-us-item" @click="toTelegram">
                                <img class="Nature-item" title="Share on Telegram"
                                    src="../../assets/images/bounty/组 3.png" alt="">
                                <p>Telegram</p>
                            </div>
                            <div class="follow-us-item" @click="toWhatsapp">
                                <img class="Nature-item" title="Share on Whatsapp"
                                    src="../../assets/images/bounty/组 2.png" alt="">
                                <p>Whatsapp</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import {
    selectProductCategoryTree,
    selectCharityList,
    bountySubscribe,
} from "@/config/api";
export default {
    name: "pageFoot",
    data() {
        return {
            email: "",
            subscribed: false,
            productCategoryTree: [],
            charityList: [],
        };
    },
    methods: {
        // 订阅处理方法
        subscribe() {
            console.log(1111111);
            if (this.email) {
                bountySubscribe({ 'email': this.email }).then((res) => {
                    this.subscribed = true;
                    // 重置输入框
                    this.email = "";
                    // 5秒后隐藏成功消息
                    setTimeout(() => {
                        this.subscribed = false;
                    }, 5000);
                });
            }
        },
        openProductChildDropdown(id) {
            this.$router.push("/category?categoryId=" + id);
        },
        openGiveShare(id) {
            this.$router.push("/charitableOrganizationDetail?id=" + id);
        },
        toBlogList() {
            this.$router.push({ path: "/blogList" });
        },
        toDownloadCenter() {
            this.$router.push({ path: "/download" });
        },
        toWomensWellness() {
            this.$router.push({ path: "/womensWellness" });
        },
        toFacebook() {
            // window.location.href =
            //     "https://www.facebook.com/profile.php?id=61582517926922";
            window.open("https://www.facebook.com/profile.php?id=61582517926922")
        },
        toTelegram() {
            // window.location.href = "http://t.me/baishi456";
            window.open("http://t.me/HarvestGain1")
        },
        toWhatsapp() {
            // window.location.href = "https://wa.me/111111";
            window.open("https://wa.me/+13032586400")
        },
    },
    created() {
        selectProductCategoryTree().then((res) => {
            if (res.code === 200) {
                this.productCategoryTree = res.data.filter(
                    (item) => item.parent == "0"
                );
            }
        });
        selectCharityList().then((res) => {
            if (res.code === 200) {
                this.charityList = res.data;
            }
        });
    },
};
</script>

<style scoped lang="less">
@media (min-width: 770px) {
    .social-media {
        width: 100vw;
    }

    .logo {
        width: 450px !important;
        max-width: 450px !important;
    }

    .item-title {
        font-size: 45px !important;
        margin-bottom: 20px !important;
    }

    .item-list-item {
        line-height: 60px !important;
        font-size: 32px !important;
    }

    .limit-height {
        max-height: auto !important;
    }

    .newsletter-desc {
        font-size: 30px;
        margin-bottom: 30px;
        line-height: 1.5;
    }

    .email-input {
        flex: 1;
        padding: 30px;
        border: none;
        border-radius: 40px 0 0 40px;
        font-size: 40px;
    }

    .subscribe-button {
        background-color: #809e2c;
        color: white;
        border: none;
        padding: 10px 15px;
        font-size: 40px;
        cursor: pointer;
        border-radius: 0 40px 40px 0;
        transition: background-color 0.3s;
    }

    .social-content {
        flex-direction: column;
    }

    .social-media .social-content .content p {
        font-size: 25px;
        color: #ffffff;
        line-height: 1.1;
    }

    .social-media .social-content .title {
        font-size: 30px !important;
        width: 300px !important;
        font-weight: bold !important;
    }
}

@media (min-width: 1680px) {
    .social-media {
        width: 1400px;
    }

    .logo {
        width: 300px !important;
        max-width: 300px !important;
    }

    .item-title {
        font-size: 18px !important;
    }

    .item-list-item {
        line-height: 28px !important;
        font-size: 15px !important;
    }

    .limit-height {
        max-height: 200px !important;
    }

    .newsletter-desc {
        font-size: 14px;
        margin-bottom: 15px;
        line-height: 1.5;
    }

    .email-input {
        flex: 1;
        padding: 10px;
        border: none;
        border-radius: 30px 0 0 30px;
        font-size: 14px;
    }

    .subscribe-button {
        background-color: #809e2c;
        color: white;
        border: none;
        padding: 10px 15px;
        font-size: 14px;
        cursor: pointer;
        border-radius: 0 30px 30px 0;
        transition: background-color 0.3s;
    }

    .social-content {
        flex-direction: row;
    }

    .social-media .social-content .content p {
        font-size: 16px;
        color: #ffffff;
        line-height: 1.8;
    }

    .social-media .social-content .title {
        font-size: 18px !important;
        width: 120px !important;
    }
}

.pageFoot {
    width: 100%;
    background-color: #2e453b;
    color: white;
    padding: 40px 0;
    font-family: Arial, sans-serif;
}

.pc-pageFoot {
    /* max-width: 1200px; */
    margin: 0 auto;
    padding: 0 20px;
}

.logo {
    display: block;
    margin: 0 auto 45px;
    max-width: 300px;
    /* height: 50px; */
}

.item-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-bottom: 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 30px;
}

.item {
    /* flex: 1; */
    min-width: 220px;
    margin-bottom: 20px;
}

.item-title {
    padding-left: 10px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #fff;
}

.item-list {
    padding: 0px 10px 0 0;
    box-sizing: border-box;
}

.item-list-item {
    flex: 1 1 calc(20% - 0.5rem);
    /* 每项占 20%，即最多 5 个/行 */
    padding: 5px 10px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.3s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.item-list-item:hover {
    opacity: 0.8;
}

/* 时事通讯样式 */
.newsletter {
    min-width: 250px;
}

.newsletter-form {
    display: flex;
    margin-bottom: 10px;
}

.subscribe-button:hover {
    background-color: #6c8a26;
}

.success-message {
    font-size: 14px;
    color: #809e2c;
    display: flex;
    align-items: center;
}

.checkmark {
    margin-right: 5px;
}

.social-Nature {
    display: flex;
    align-items: center;

    .Nature-item {
        padding: 0px 20px;
        border-right: 2px solid #fff;
        color: #ffffff;
        line-height: 1;
    }
}

/* 社交媒体样式 */
.social-media {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding-top: 20px;

    .social-content {
        display: flex;
        align-items: start;
        justify-content: space-around;
        width: 100%;

        .title {
            padding: 8px 20px;
            background: #ffffff;
            border-radius: 8px;
            color: #2e453b;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 18px;
        }

        .content {
            margin-top: 20px;
            padding: 10px 20px 20px 0;
        }

        .follow-us .content {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .follow-us-item {}

        .follow-us-item+.follow-us-item {
            margin-left: 20px;
        }

        .Nature-item {
            width: 50px;
            height: 50px;
            transition: transform 0.3s ease;
        }

        .Nature-item:hover {
            transform: translateY(-10px);
            opacity: 0.8;
        }
    }
}

.follow-us {
    font-size: 14px;
    color: #ffffff;
}

.social-icons {
    display: flex;
    gap: 15px;
}

.social-icon {
    color: white;
    text-decoration: none;
    font-size: 14px;
    transition: opacity 0.3s;
}

.social-icon:hover {
    opacity: 0.8;
}

.social-icon-img {
    width: auto;
    height: 18px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .item-content {
        flex-direction: column;
        align-items: center;
    }

    .item {
        text-align: center;
        margin-bottom: 30px;
    }

    .newsletter-form {
        flex-direction: column;
    }

    .subscribe-button {
        margin-top: 10px;
    }

    .social-media {
        flex-direction: column;
        gap: 10px;
    }
}
</style>
